package demo.util_ui.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockPanel;

/**
 * Dialog with "close" button.
 * Modal by default.
 * @author psriplakich
 *
 */
public class SimpleDialog extends AbstractDialog {

	final Button closeButton = new Button("Close");

	public SimpleDialog() {
		this(null);

	}

	/**
	 * 
	 * @param closeLabel  label of the close button.
	 */
	public SimpleDialog(final String closeLabel) {
		this(closeLabel, false);
	}

	/**
	 * 
	 * @param closeLabel label of the close button.
	 * @param modal whether or not the dialog is modal.
	 */
	public SimpleDialog(final String closeLabel, final boolean modal) {
		super();

		this.closeButton.getElement().setId("closeButton");

		if (null != closeLabel) {
			this.closeButton.setHTML(closeLabel);
		}
		// Add a handler to close the DialogBox
		this.closeButton.addClickHandler(new ClickHandler() {
			public void onClick(final ClickEvent event) {
				hide();
				onCloseButtonClicked();
			}
		});

		this.bottomPanel.add(this.closeButton, DockPanel.EAST);

		this.setModal(modal);
	}

	@Override
	public void center() {
		super.center();
	}

	protected void onCloseButtonClicked() {

	}

}
